package com.neuedu.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.neuedu.domain.Articleinfo;
import com.neuedu.domain.Commentinfo;
import com.neuedu.domain.Userinfo;
import com.neuedu.service.ArticleService;
import com.neuedu.service.impl.ArticleServiceImpl;

@WebServlet("/article/cainacc")
public class ArticleCainAccServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.getWriter().append("Served at: ").append(request.getContextPath());
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String authorid = request.getParameter("authorid");
		String acckiss = request.getParameter("paykiss");
		Commentinfo ci = new Commentinfo();
		ci.setAcckiss(Integer.parseInt(acckiss));
		ci.setAuthorid(Integer.parseInt(authorid));		
		ArticleService as = new ArticleServiceImpl();
		int count = as.upIsaccept(ci);
		Userinfo user =(Userinfo)request.getSession().getAttribute("login_user");
		user.setKissnum(user.getKissnum()+Integer.parseInt(acckiss));
		response.getWriter().print(count);
	}

}
